home *** CD-ROM | disk | FTP | other *** search
- ''''''''''''''''''''''''''''''''''''''''''''''''''
- ' '
- ' General Phone List '
- ' ------------------ '
- ' '
- ' CREATED BY APG '
- ' S & M SOFTWARE '
- ' COPYRIGHT 1993 '
- ' '
- ' USE file is PHONE.USE '
- ' '
- ' Author: S&M Software '
- ' Date: 03-18-1993 '
- ' Time: 10:39:13 '
- ' '
- ' USE file Created USE file Modified '
- ' Date: 03-10-1993 Date: 03-14-1993 '
- ' Time: 22:50:08 Time: 11:18:01 '
- ''''''''''''''''''''''''''''''''''''''''''''''''''
-
-
- DEFINT A-Z
- CONST FALSE = 0, TRUE = NOT FALSE
- TYPE rectype 'Define variables for file
- pnbr AS STRING * 12
- xName20 AS STRING * 30
- xAddress AS STRING * 25
- xcity40 AS STRING * 20
- xstate50 AS STRING * 2
- xZip60 AS STRING * 10
- xSpouse AS STRING * 10
- xData80 AS STRING * 8
- xGift90 AS INTEGER
- sts AS STRING * 1
- END TYPE
- TYPE indextype 'Define index
- recnum AS INTEGER
- pnbr AS STRING * 12
- END TYPE
- DECLARE FUNCTION getinput$ (work$, fl%, nflg$, plen, prec, form$, act$, mode$)
- DECLARE SUB arrow (mode$, opt$, tracfld)
- DECLARE SUB clearfore ()
- DECLARE SUB displaydata ()
- DECLARE SUB export ()
- DECLARE SUB message (msg$, resp$)
- DECLARE SUB newrec (recnum, numofrec, maxrec, newkey$, exit$, mode$)
- DECLARE SUB nextrec (direc$, exit$, numofrec, recnum)
- DECLARE SUB sortindex ()
- DIM SHARED numofrec
- DIM SHARED f3.0$
- DIM SHARED phone AS rectype
- f3.0$ = "####"
-
- ON ERROR GOTO errhandle
-
- COLOR 15, 0
- CLS
-
- OPEN "PHONE.DAT" FOR RANDOM AS #1 LEN = LEN(phone)
-
- numofrec = LOF(1) \ LEN(phone)
- maxrec = numofrec + 100
- DIM SHARED index(1 TO maxrec) AS indextype
- IF numofrec <> 0 THEN
- FOR recnum = 1 TO numofrec
- GET #1, recnum, phone
- index(recnum).recnum = recnum
- index(recnum).pnbr = phone.pnbr
- NEXT
- END IF
- '
- '----- Print menu -----'
- '
- LOCATE 1, 29
- COLOR 7, 9
- PRINT "│ │"
- LOCATE 1, 31
- PRINT "General Phone List"
- LOCATE 2, 29
- PRINT "│ │"
- LOCATE 2, 31
- PRINT "------------------"
- sortindex 'sort records
- recnum = 0 'reset record number
-
- LOCATE 5, 5: PRINT "01-Phone Number "
- LOCATE 7, 5: PRINT "02-Name "
- LOCATE 8, 5: PRINT "03-Address "
- LOCATE 9, 5: PRINT "04-City "
- LOCATE 10, 5: PRINT "05-State "
- LOCATE 11, 5: PRINT "06-Zip Code "
- LOCATE 13, 5: PRINT "07-Spouse's Name "
- LOCATE 14, 5: PRINT "08-Birthday "
- LOCATE 15, 5: PRINT "09-Gift Amount "
- '
- '----- Start processing -----'
- '
- start:
- mode$ = ""
- phone.pnbr = ""
- phone.xName20 = ""
- phone.xAddress = ""
- phone.xcity40 = ""
- phone.xstate50 = ""
- phone.xZip60 = ""
- phone.xSpouse = ""
- phone.xData80 = ""
- phone.xGift90 = 0
- phone.sts = ""
- nflg$ = ""
- clearfore
- LOCATE 5, 24
- newkey$ = getinput$(phone.pnbr, 12, "L", 0, 0, "", act$, mode$)
- IF act$ = "PU" OR act$ = "PD" THEN
- opt$ = act$
- IF recnum = 0 THEN
- IF opt$ = "PU" AND numofrec <> 0 THEN recnum = numofrec + 1
- END IF
- GOTO menu10
- END IF
- IF newkey$ = " " GOTO fin
- IF UCASE$(newkey$) = "N " THEN
- opt$ = "N"
- GOTO menu10
- END IF
- GOTO io
- '
- '------ Option bar -----'
- '
- menu:
- mode$ = "C"
- LOCATE 23, 1
- PRINT STRING$(80, " ")
- LOCATE 23, 12, 1
- COLOR 7, 9
- PRINT "FIELD #, PgUp, PgDn, ";
- PRINT "All, Next, Back, Delete, Sort, Export";
- COLOR 15, 0
- PRINT " "
- COLOR 15, 9
- LOCATE 23, 18: PRINT "#"
- LOCATE 23, 33: PRINT "A"
- LOCATE 23, 38: PRINT "N"
- LOCATE 23, 44: PRINT "B"
- LOCATE 23, 50: PRINT "D"
- LOCATE 23, 58: PRINT "S"
- LOCATE 23, 64: PRINT "E"
-
- COLOR 15, 0
- opt$ = ""
- menu5:
- LOCATE 23, 71
- PRINT opt$;
- DO
- instr$ = INKEY$
- LOOP WHILE instr$ = ""
-
- IF INSTR("BANDSE", UCASE$(instr$)) > 0 THEN opt$ = instr$: GOTO menu10
- IF instr$ = CHR$(13) GOTO menu10
- IF instr$ = CHR$(27) GOTO menu
- IF instr$ = CHR$(8) GOTO menu
- IF LEN(instr$) = 2 THEN
- code = ASC(RIGHT$(instr$, 1))
- IF code = &H49 THEN opt$ = "PU"
- IF code = &H51 THEN opt$ = "PD"
- GOTO menu10
- END IF
- opt$ = opt$ + instr$
- GOTO menu5
- '
- '----- Start here for action keys -----'
- '
- menu10:
- resp$ = ""
- IF opt$ = "" THEN GOTO start
- opt$ = UCASE$(opt$)
- IF MID$(opt$, 1, 1) = "0" THEN opt$ = MID$(opt$, 2, 1)
- LOCATE 23, 1
- PRINT STRING$(80, " ")
- LOCATE 23, 6, 1
- COLOR 7, 9
- IF INSTR("SEBNPUPD", opt$) = 0 THEN
- PRINT "Active Keys: <PgUp>, <PgDn>, <Arrows>, <Del>, <Ins>, <Esc> or <Enter>";
- COLOR 15, 9
- LOCATE 23, 20: PRINT "PgUp";
- LOCATE 23, 28: PRINT "PgDn";
- LOCATE 23, 36: PRINT "Arrows";
- LOCATE 23, 46: PRINT "Del";
- LOCATE 23, 53: PRINT "Ins";
- LOCATE 23, 60: PRINT "Esc";
- LOCATE 23, 69: PRINT "Enter";
- END IF
- COLOR 15, 0
-
- SELECT CASE opt$
- CASE "1"
- message "Can not change index - Press any key", resp$
- GOTO menu
- CASE "2"
- GOTO fld20 'Name
- CASE "3"
- GOTO fld30 'Address
- CASE "4"
- GOTO fld40 'City
- CASE "5"
- GOTO fld50 'State
- CASE "6"
- GOTO fld60 'Zip Code
- CASE "7"
- GOTO fld70 'Spouse's Name
- CASE "8"
- GOTO fld80 'Birthday
- CASE "9"
- GOTO fld90 'Gift Amount
- CASE "A"
- mode$ = "A"
- GOTO fld20
- CASE "N", "PD"
- direc$ = "F"
- nextrec direc$, exit$, numofrec, recnum
- IF exit$ = "A" GOTO start
- GOTO menu
- CASE "B", "PU"
- direc$ = "B"
- nextrec direc$, exit$, numofrec, recnum
- IF exit$ = "A" GOTO start
- GOTO menu
- CASE "D"
- phone.sts = "D"
- GOTO del
- CASE "S"
- resp$ = "1"
- message "Sorting file - Please wait", resp$
- sortindex
- resp$ = "2"
- message "", resp$
- CASE "E"
- CLOSE (2)
- KILL "phone.exp"
- resp$ = "1"
- message "Preparing file for export - Please wait", resp$
- export
- resp$ = "2"
- message "", resp$
- GET #1, recnum, phone
- END SELECT
- GOTO menu
- '
- '----- Input fields -----'
- '
- fld20: 'Name
- tracfld = 2
- LOCATE 7, 24
- phone.xName20 = getinput$(phone.xName20, 30, "L", 0, 0, "", act$, mode$)
- LOCATE 25, 1
- PRINT STRING$(80, " ");
- IF phone.xName20 = " " AND mode$ <> "C" THEN
- GOTO start
- END IF
- IF mode$ = "C" OR act$ <> "" GOTO add
-
- fld30: 'Address
- tracfld = 3
- LOCATE 8, 24
- phone.xAddress = getinput$(phone.xAddress, 25, "L", 0, 0, "", act$, mode$)
- IF mode$ = "C" OR act$ <> "" GOTO add
-
- fld40: 'City
- tracfld = 4
- LOCATE 9, 24
- phone.xcity40 = getinput$(phone.xcity40, 20, "L", 0, 0, "", act$, mode$)
- IF mode$ = "C" OR act$ <> "" GOTO add
-
- fld50: 'State
- tracfld = 5
- LOCATE 10, 24
- phone.xstate50 = getinput$(phone.xstate50, 2 , "L", 0, 0, "", act$, mode$)
- IF mode$ = "C" OR act$ <> "" GOTO add
-
- fld60: 'Zip Code
- tracfld = 6
- LOCATE 11, 24
- phone.xZip60 = getinput$(phone.xZip60, 10, "L", 0, 0, "", act$, mode$)
- IF mode$ = "C" OR act$ <> "" GOTO add
-
- fld70: 'Spouse's Name
- tracfld = 7
- LOCATE 13, 24
- phone.xSpouse = getinput$(phone.xSpouse, 10, "L", 0, 0, "", act$, mode$)
- IF mode$ = "C" OR act$ <> "" GOTO add
-
- fld80: 'Birthday
- tracfld = 8
- LOCATE 14, 24
- phone.xData80 = getinput$(phone.xData80, 8 , "L", 0, 0, "", act$, mode$)
- IF mode$ = "C" OR act$ <> "" GOTO add
-
- fld90: 'Gift Amount
- tracfld = 9
- LOCATE 15, 24
- IF mode$ = "N" THEN
- xGift90$ = STRING$( 5, " ")
- ELSE
- xGift90$ = STR$(phone.xGift90) + STRING$( 5, " ")
- END IF
- phone.xGift90 = VAL(getinput$(xGift90$, 5, "N", 3, 0, f3.0$, act$, mode$))
- IF mode$ = "C" OR act$ <> "" GOTO add
-
- '
- '----- Add or change record or field -----'
- '
- add: 'Add record
- newrec recnum, numofrec, maxrec, newkey$, exit$, mode$
- IF exit$ = "Y" THEN GOTO fin
- IF act$ = "" GOTO menu
- IF act$ = "PD" THEN direc$ = "F"
- IF act$ = "PU" THEN direc$ = "B"
- IF act$ = "PD" OR act$ = "PU" THEN
- nextrec direc$, exit$, numofrec, recnum
- IF exit$ = "A" GOTO start
- GOTO menu10
- END IF
- IF mode$ = "N" THEN mode$ = "Z"
- IF act$ = "AU" THEN
- IF tracfld - 1 < 2 THEN
- BEEP
- tracfld = 3
- END IF
- opt$ = MID$(STR$(tracfld - 1), 2)
- GOTO menu10
- END IF
- IF act$ = "AD" THEN
- IF tracfld + 1 > 9 THEN
- BEEP
- tracfld = 8
- END IF
- opt$ = MID$(STR$(tracfld + 1), 2)
- GOTO menu10
- END IF
-
- del: 'Delete record
- PUT #1, index(recnum).recnum, phone
- phone.sts = ""
- GOTO start
- '
- '----- Set for new or get exsisting record -----'
- '
- io:
- FOR recnum = 1 TO numofrec
- IF index(recnum).pnbr = newkey$ THEN GOTO io10
- NEXT
- mode$ = "N"
- phone.pnbr = newkey$
- resp$ = "1"
- message "New record - Enter field data or <ENTER> to abort", resp$
- GOTO fld20
- io10:
- GET #1, index(recnum).recnum, phone
- IF phone.sts = "D" THEN
- message "This record has been deleted - Do you wish to restore y/N ", resp$
- IF UCASE$(resp$) = "Y" THEN
- phone.sts = ""
- PUT #1, index(recnum).recnum, phone
- ELSE
- GOTO start
- END IF
- END IF
- displaydata
- GOTO menu
- '
- '----- End program -----'
- '
- fin:
- CLS
- CLOSE
- END
- '
- '----- Error handling -----'
- '
- errhandle:
- IF ERR = 53 THEN
- RESUME NEXT
- END IF
- CLS
- PRINT "Unexpected error "; ERR
- PRINT "Please note this error number and consult your QuickBasic Manual!"
- INPUT "", a$
- CLOSE
- END
-
- SUB arrow (mode$, opt$, tracfld)
- IF mode$ = "AU" THEN
- opt$ = MID$(STR$(tracfld - 1), 2)
- EXIT SUB
- END IF
- IF mode$ = "AD" THEN
- opt$ = MID$(STR$(tracfld + 1), 2)
- EXIT SUB
- END IF
- END SUB
-
- SUB clearfore
- COLOR 15, 0
- LOCATE 5, 24
- PRINT STRING$(12, " ")
- LOCATE 7, 24
- PRINT STRING$(30, " ")
- LOCATE 8, 24
- PRINT STRING$(25, " ")
- LOCATE 9, 24
- PRINT STRING$(20, " ")
- LOCATE 10, 24
- PRINT STRING$(2, " ")
- LOCATE 11, 24
- PRINT STRING$(10, " ")
- LOCATE 13, 24
- PRINT STRING$(10, " ")
- LOCATE 14, 24
- PRINT STRING$(8, " ")
- LOCATE 15, 24
- PRINT STRING$(5, " ")
- LOCATE 23, 1
- PRINT STRING$(80, " ")
- LOCATE 23, 4
- PRINT "Enter key information, <N> for next, <PgUp>, <PgDn>, or <ENTER> to exit"
- END SUB
-
- SUB displaydata
- LOCATE 5, 24: PRINT phone.pnbr
- LOCATE 7, 24: PRINT phone.xName20
- LOCATE 8, 24: PRINT phone.xAddress
- LOCATE 9, 24: PRINT phone.xcity40
- LOCATE 10, 24: PRINT phone.xstate50
- LOCATE 11, 24: PRINT phone.xZip60
- LOCATE 13, 24: PRINT phone.xSpouse
- LOCATE 14, 24: PRINT phone.xData80
- LOCATE 15, 24: PRINT USING f3.0$; phone.xGift90
- END SUB
-
- SUB export
- q$ = CHR$(34)
- OPEN "phone.exp" FOR OUTPUT AS #2
-
- FOR i = 1 TO numofrec
- GET #1, i, phone
- data$ = q$ + phone.pnbr + q$ + ","
- data$ = data$ + q$ + phone.xName20 + q$ + ","
- data$ = data$ + q$ + phone.xAddress + q$ + ","
- data$ = data$ + q$ + phone.xcity40 + q$ + ","
- data$ = data$ + q$ + phone.xstate50 + q$ + ","
- data$ = data$ + q$ + phone.xZip60 + q$ + ","
- data$ = data$ + q$ + phone.xSpouse + q$ + ","
- data$ = data$ + q$ + phone.xData80 + q$ + ","
- data$ = data$ + STR$(phone.xGift90)
- PRINT #2, data$
- NEXT i
- END SUB
-
- FUNCTION getinput$ (work$, fl, nflg$, plen, prec, form$, act$, mode$)
- '
- ' ----- set varailbles -----'
- '
- crow = CSRLIN
- ccol = POS(0)
- beg = ccol - 1
- maxcol = ccol + fl - 1
- mincol = ccol
- new$ = "N"
- act$ = ""
- GOTO begin5
- '
- ' ----- get inputed character -----'
- '
- begin:
- BEEP
- begin5:
- dotpos = INSTR(work$, ".")
- signpos = INSTR(work$, "-")
- IF dotpos = 0 THEN dot = 0
- IF signpos = 0 THEN sign = 0
- code = 0
- LOCATE crow, mincol, 1
- IF nflg$ = "L" OR edit$ = "Y" THEN PRINT work$;
- work# = VAL(work$)
- IF nflg$ = "N" AND edit$ = "" THEN PRINT USING form$; work#
- LOCATE crow, ccol, , 7
- IF insert$ = "Y" THEN LOCATE crow, ccol, 1, 0, 7
- DO
- instr$ = INKEY$
- LOOP WHILE instr$ = ""
- '
- ' ----- is it a special character? -----'
- '
- IF instr$ = CHR$(27) THEN work$ = STRING$(fl, " "): ccol = mincol: GOTO begin5
- IF instr$ = CHR$(8) THEN dir$ = "L": key$ = "B": GOTO begin10
- IF LEN(instr$) = 2 THEN
- code = ASC(RIGHT$(instr$, 1))
- IF code = &H4B THEN dir$ = "L": key$ = "L": GOTO begin10 'Left arrow
- IF code = &H4D THEN dir$ = "R": key$ = "R": GOTO begin10 'Right arrow
- IF code = &H4F THEN dir$ = "R": key$ = "E": GOTO begin10 'End
- IF code = &H47 THEN dir$ = "L": key$ = "H": GOTO begin10 'Home
- IF code = &H52 THEN 'Insert
- IF insert$ = "" THEN
- dir$ = "L"
- key$ = "I"
- insert$ = "Y"
- GOTO begin10
- ELSE
- insert$ = ""
- dir$ = "R"
- key$ = "R"
- GOTO begin10
- END IF
- END IF
- IF code = &H53 THEN dir$ = "R": key$ = "D": GOTO begin10 'Delete
- IF code = &H49 THEN act$ = "PU": GOTO begin10 'Page up
- IF code = &H51 THEN act$ = "PD": GOTO begin10 'Page down
- IF code = &H48 THEN act$ = "AU": GOTO begin10 'Up arrow
- IF code = &H50 THEN act$ = "AD": GOTO begin10 'Down arrow
- GOTO begin
- ELSE
- dir$ = "R": key$ = "R"
- END IF
- '
- ' ----- does this character request an exit? ------ '
- '
- begin10:
- IF instr$ = CHR$(13) OR LEN(act$) = 2 THEN
- IF nflg$ = "L" THEN
- getinput$ = work$
- EXIT FUNCTION
- ELSE
- dec = INSTR(work$, ".")
- IF dec = 0 AND edit$ = "Y" THEN
- IF prec = 0 THEN
- getinput$ = work$
- EXIT FUNCTION
- END IF
- factor$ = "." + RIGHT$("000000000001", prec)
- worknum# = VAL(work$) * VAL(factor$)'
- getinput$ = STR$(worknum#)
- EXIT FUNCTION
- ELSE
- getinput$ = work$
- EXIT FUNCTION
- END IF
- END IF
- END IF
- IF code = 0 AND instr$ <> CHR$(8) GOTO valid
- '
- ' ----- perform action of special key ----- '
- '
- IF dir$ = "R" AND ccol = maxcol THEN GOTO begin
- IF dir$ = "L" AND ccol = mincol AND key$ = "B" AND LEN(RTRIM$(work$)) = 1 THEN
- MID$(work$, 1, 1) = " ": GOTO begin5
- END IF
- IF dir$ = "L" AND ccol = mincol THEN GOTO begin
- SELECT CASE key$
- CASE "L"
- ccol = ccol - 1
- CASE "R"
- ccol = ccol + 1
- IF ccol > maxcol THEN
- BEEP
- ccol = maxcol
- END IF
- CASE "E"
- ccol = mincol + LEN(RTRIM$(work$))
- CASE "H"
- ccol = mincol
- CASE "D"
- work$ = MID$(work$, 1, ccol - beg - 1) + MID$(work$, ccol - beg + 1, fl) + " "
- CASE "B"
- work$ = MID$(work$, 1, ccol - beg - 2) + MID$(work$, ccol - beg, fl) + " "
- ccol = ccol - 1
- END SELECT
- GOTO begin5
- '
- ' ----- check validity of inputed character ----- '
- '
- valid:
-
- IF nflg$ = "L" THEN
- IF insert$ = "Y" THEN
- work1$ = MID$(work$, 1, ccol - beg - 1)
- work2$ = MID$(work$, ccol - beg, fl)
- work$ = work1$ + instr$ + work2$
- work$ = MID$(work$, 1, fl)
- ccol = ccol + 1
- IF ccol > maxcol THEN
- ccol = maxcol
- GOTO begin
- END IF
- GOTO begin5
- END IF
- MID$(work$, ccol - beg) = instr$
- ccol = ccol + 1
- IF ccol > maxcol THEN
- ccol = maxcol
- GOTO begin
- END IF
- GOTO begin5
- END IF
- IF new$ = "N" THEN
- blen = plen + prec + 2
- blank$ = STRING$(blen, " ")
- work$ = blank$: new$ = ""
- END IF
- IF ccol = mincol THEN
- PRINT work$
- LOCATE crow, mincol
- edit$ = "Y"
- first = INSTR("-.1234567890", instr$)
- SELECT CASE first
- CASE 0
- GOTO begin
- CASE 1
- sign = 1
- GOTO accept
- CASE 2
- IF dot = 1 THEN
- GOTO begin
- END IF
- dot = 1
- GOTO accept
- END SELECT
- GOTO accept
- END IF
- other = INSTR(".1234567890", instr$)
- SELECT CASE other
- CASE 0
- GOTO begin
- CASE 1
- IF dot = 1 THEN
- GOTO begin
- END IF
- dot = 1
- GOTO accept
- END SELECT
- GOTO accept
- '
- ' ------ accept valid numeric and manipulate ----- '
- '
- accept:
- IF prec = 0 THEN
- IF instr$ = "." AND ccol <> mincol + plen + sign GOTO begin
- maxlen = plen + sign + dot
- IF LEN(RTRIM$(work$)) = maxlen THEN
- GOTO begin
- ELSE
- MID$(work$, ccol - beg) = instr$
- ccol = ccol + 1
- GOTO accept10
- END IF
- END IF
-
- dotpos = INSTR(work$, ".")
- IF dotpos = 0 THEN
- maxlen = plen + sign
- IF LEN(RTRIM$(work$)) = maxlen THEN
- IF instr$ <> "." THEN
- MID$(work$, ccol - beg) = "." + instr$
- ccol = ccol + 2
- GOTO accept10
- ELSE
- MID$(work$, ccol - beg) = instr$
- ccol = ccol + 1
- GOTO accept10
- END IF
- ELSE
- MID$(work$, ccol - beg) = instr$
- ccol = ccol + 1
- GOTO accept10
- END IF
- ELSE
- IF instr$ = "." THEN GOTO begin
- maxlenpr = prec + dotpos
- IF prec = 0 THEN maxlenpr = plen
- IF LEN(RTRIM$(work$)) = maxlenpr THEN
- GOTO begin
- ELSE
- MID$(work$, ccol - beg) = instr$
- ccol = ccol + 1
- GOTO accept10
- END IF
- END IF
- accept10:
- GOTO begin5
-
- END FUNCTION
-
- SUB message (msg$, resp$)
- '
- ' resp$ = "" wait for response
- ' resp$ = "1" don't clear message, exit
- ' resp$ = "2" clear message, exit
- '
- IF resp$ = "2" THEN GOTO msg10
- IF resp$ = "" THEN BEEP
- Y = (80 - LEN(msg$)) / 2
- LOCATE 23, 1
- PRINT STRING$(80, " ")
- LOCATE 25, Y, 0
- PRINT msg$;
- IF resp$ = "1" THEN EXIT SUB
- DO
- resp$ = INKEY$
- LOOP WHILE resp$ = ""
- LOCATE 25, Y
- PRINT STRING$(LEN(msg$), " ");
- EXIT SUB
- msg10:
- LOCATE 25, 1
- PRINT STRING$(80, " ");
- END SUB
-
- SUB newrec (recnum, numofrec, maxrec, newkey$, exit$, mode$)
- IF mode$ = "N" THEN
- numofrec = numofrec + 1
- IF numofrec = maxrec THEN
- message "Can not add any more records this session - Restart", resp$
- exit$ = "Y"
- END IF
- PUT #1, numofrec, phone
- index(numofrec).recnum = numofrec
- index(numofrec).pnbr = newkey$
- ELSE
- PUT #1, index(recnum).recnum, phone
- END IF
- END SUB
-
- SUB nextrec (direc$, exit$, numofrec, recnum)
- exit$ = ""
- IF direc$ = "F" THEN recnum = recnum + 1
- IF direc$ = "B" THEN recnum = recnum - 1
- IF recnum > numofrec THEN
- message "End of file - Press any key", resp$
- recnum = 0
- exit$ = "A"
- EXIT SUB
- END IF
- IF recnum = 0 THEN
- message "Start of file - Press any key", resp$
- exit$ = "A"
- EXIT SUB
- END IF
- get #1, index(recnum).recnum, phone
- IF phone.sts = "D" THEN
- message "This record has been deleted - Do you wish to restore y/N ", resp$
- IF UCASE$(resp$) = "Y" THEN
- phone.sts = ""
- PUT #1, index(recnum).recnum, phone
- ELSE
- exit$ = "A"
- EXIT SUB
- END IF
- END IF
- displaydata
- END SUB
-
- SUB sortindex STATIC
- SHARED index() AS indextype, numofrec
- offset = numofrec \ 2
- DO WHILE offset > 0
- limit = numofrec - offset
- DO
- switch = FALSE
- FOR i = 1 TO limit
- IF index(I).pnbr > index(I + offset).pnbr THEN
- SWAP index(i), index(i + offset)
- switch = i
- END IF
- NEXT i
- limit = switch
- LOOP WHILE switch
- offset = offset \ 2
- LOOP
- END SUB
-
-